﻿#region License
/*
 Microsoft Public License (Ms-PL)
 MonoGame - Copyright © 2012 The MonoGame Team
 
 All rights reserved.
 
 This license governs use of the accompanying software. If you use the software, you accept this license. If you do not
 accept the license, do not use the software.
 
 1. Definitions
 The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under 
 U.S. copyright law.
 
 A "contribution" is the original software, or any additions or changes to the software.
 A "contributor" is any person that distributes its contribution under this license.
 "Licensed patents" are a contributor's patent claims that read directly on its contribution.
 
 2. Grant of Rights
 (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, 
 each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create.
 (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, 
 each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software.
 
 3. Conditions and Limitations
 (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
 (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, 
 your patent license from such contributor to the software ends automatically.
 (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution 
 notices that are present in the software.
 (D) If you distribute any portion of the software in source code form, you may do so only under this license by including 
 a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object 
 code form, you may only do so under a license that complies with this license.
 (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees
 or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent
 permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular
 purpose and non-infringement.
 */
#endregion License

using Microsoft.Xna.Framework.Graphics;

namespace Microsoft.Xna.Framework.Content.Pipeline
{
    /// <summary>
    /// Provides access to custom processor parameters, methods for converting member data, and triggering nested builds.
    /// </summary>
    public abstract class ContentProcessorContext
    {
        /// <summary>
        /// Gets the name of the current content build configuration.
        /// </summary>
        public abstract string BuildConfiguration { get; }

        /// <summary>
        /// Gets the path of the directory that will contain any intermediate files generated by the content processor.
        /// </summary>
        public abstract string IntermediateDirectory { get; }

        /// <summary>
        /// Gets the logger interface used for status messages or warnings.
        /// </summary>
        public abstract ContentBuildLogger Logger { get; }

        /// <summary>
        /// Gets the output path of the content processor.
        /// </summary>
        public abstract string OutputDirectory { get; }

        /// <summary>
        /// Gets the output file name of the content processor.
        /// </summary>
        public abstract string OutputFilename { get; }

        /// <summary>
        /// Gets the collection of parameters used by the content processor.
        /// </summary>
        public abstract OpaqueDataDictionary Parameters { get; }

        /// <summary>
        /// Gets the current content build target platform.
        /// </summary>
        public abstract TargetPlatform TargetPlatform { get; }

        /// <summary>
        /// Gets the current content build target profile.
        /// </summary>
        public abstract GraphicsProfile TargetProfile { get; }

        /// <summary>
        /// Initializes a new instance of ContentProcessorContext.
        /// </summary>
        public ContentProcessorContext()
        {
        }

        /// <summary>
        /// Adds a dependency to the specified file. This causes a rebuild of the file, when modified, on subsequent incremental builds.
        /// </summary>
        /// <param name="filename">Name of an asset file.</param>
        public abstract void AddDependency(string filename);

        /// <summary>
        /// Add a file name to the list of related output files maintained by the build item. This allows tracking build items that build multiple output files.
        /// </summary>
        /// <param name="filename">The name of the file.</param>
        public abstract void AddOutputFile(string filename);

        /// <summary>
        /// Initiates a nested build of the specified asset and then loads the result into memory.
        /// </summary>
        /// <typeparam name="TInput">Type of the input.</typeparam>
        /// <typeparam name="TOutput">Type of the converted output.</typeparam>
        /// <param name="sourceAsset">Reference to the source asset.</param>
        /// <param name="processorName">Optional processor for this content.</param>
        /// <returns>Copy of the final converted content.</returns>
        public TOutput BuildAndLoadAsset<TInput,TOutput>(
            ExternalReference<TInput> sourceAsset,
            string processorName
            )
        {
            return BuildAndLoadAsset<TInput, TOutput>(sourceAsset, processorName, null, null);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TInput"></typeparam>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="sourceAsset"></param>
        /// <param name="processorName"></param>
        /// <param name="processorParameters"></param>
        /// <param name="importerName"></param>
        /// <returns></returns>
        public abstract TOutput BuildAndLoadAsset<TInput,TOutput>(
            ExternalReference<TInput> sourceAsset,
            string processorName,
            OpaqueDataDictionary processorParameters,
            string importerName
            );

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TInput"></typeparam>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="sourceAsset"></param>
        /// <param name="processorName"></param>
        /// <returns></returns>
        public ExternalReference<TOutput> BuildAsset<TInput,TOutput>(
            ExternalReference<TInput> sourceAsset,
            string processorName
            )
        {
            return BuildAsset<TInput, TOutput>(sourceAsset, processorName, null, null, null);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TInput"></typeparam>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="sourceAsset"></param>
        /// <param name="processorName"></param>
        /// <param name="processorParameters"></param>
        /// <param name="importerName"></param>
        /// <param name="assetName"></param>
        /// <returns></returns>
        public abstract ExternalReference<TOutput> BuildAsset<TInput,TOutput>(
            ExternalReference<TInput> sourceAsset,
            string processorName,
            OpaqueDataDictionary processorParameters,
            string importerName,
            string assetName
            );

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TInput"></typeparam>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="input"></param>
        /// <param name="processorName"></param>
        /// <returns></returns>
        public TOutput Convert<TInput,TOutput>(
            TInput input,
            string processorName
            )
        {
            return Convert<TInput, TOutput>(input, processorName, new OpaqueDataDictionary());
        }

        /// <summary>
        /// 
        /// </summary>
        /// <typeparam name="TInput"></typeparam>
        /// <typeparam name="TOutput"></typeparam>
        /// <param name="input"></param>
        /// <param name="processorName"></param>
        /// <param name="processorParameters"></param>
        /// <returns></returns>
        public abstract TOutput Convert<TInput,TOutput>(
            TInput input,
            string processorName,
            OpaqueDataDictionary processorParameters
            );
    }
}
